<%--
    fileName      : /adsmanage/cfsadsinfo.jsp
    author        : user
    createDate    : 2017-02-15  
    lastModifier  : user
    lastModifyDate: 2017-02-15       
    description   : 列表页面
--%>
<%@ page language='java' contentType='text/html; charset=UTF-8' pageEncoding='UTF-8' %>
<%@ taglib uri='ctp-tag' prefix='ctp' %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <title></title>

        <ctp:include items='public,validator,groupbox,borderlayout,panel,form,button,toolbar,gridlayout,label,textfield,combobox,checkboxgroup,datepicker,grid,menus,chain,message_ex,link'/>

        <script type='text/javascript' kind='variant'>

            var borderlayout1;
            var querycondition;       //查询条件
            var queryForm;
            var queryGridlayout;
            var system; //系统
            var httpPath; //图片相对路径
            var filePath; //图片存储路径
            var reset;                //重置    
            var submit;               //提交
            var v_cfsadsinfoId = "";		  //方法域中记录问题ID的变量
            var v_urlFirst='';
            var openFrom = '0';
            var queryGroupbox;
        </script>
        <script type='text/javascript' kind='event'>

	        /*
	         * @method addRecord
	         * @desc  新增信息
	         * @author user
	         */
 			function addRecord(){
     			window.location.href="<ctp:url href='cfsadsinfomain.flowc' flowActionName='cfsadsinfodetail'/>" + "&flag=0";
            }
            /*
	         * @method isChecked
	         * @desc  判断是否已选择数据
	         * @author user
	         */
           	function isChecked(){
           		v_cfsadsinfoId = prolist.getSelectedRowId();
           		if(v_cfsadsinfoId != null && v_cfsadsinfoId != ""){
               		return true;
               	}else{
                   	return false;
                }
            }
           	/*
	         * @method modifyRecord
	         * @desc  修改信息
	         * @author user
	         */
            function modifyRecord(){
            	
                if(isChecked()){
                	var selects = prolist.getAllSelectedRowId();
                	if(selects.length > 1){
                		ctpMSB.alert({message:'<ctp:label key="mondify_one_record"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                		return;
                    }
                	window.location.href="<ctp:url href='cfsadsinfomain.flowc' flowActionName='cfsadsinfodetail'/>" + "&flag=1"+"&system="+v_cfsadsinfoId;
                }else{
                	ctpMSB.alert({message:'<ctp:label key="select_data"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                }
            }
			/*
	         * @method delHandler
	         * @desc  删除Handler
	         * @author user
	         */
			function delHandler(tp){
				if(tp == "ok"){
					ctp.data.getJSONA({	
						url:'<ctp:url href="cfsadsinfomain.flowc" flowActionName="delcfsadsinfo"/>',
						reqData : "system=" + v_cfsadsinfoId,
						success :function(data){
									if(data && data[0].retCode =="0"){
										ctpMSB.alert({title :'<ctp:label key="delete_record"/>', message:'<ctp:label key="delete_succ"/>'});
										var url = '<ctp:url href="cfsadsinfomain.flowc" flowActionName="querycfsadsinfo" />'+ '&fetchNum=36&begNum='+((prolist.footer.getCurPage()-1)*12+1)+getQueryInfo();;
										prolist.loadData(url);
									}							
									else {
										ctpMSB.alert({title:'<ctp:label key="delete_record"/>',message:'<ctp:label key="delete_fail"/>'});
									}
								}
					});
			 	}
			}

			/*
	         * @method delHandler
	         * @desc  启用Handler
	         * @author user
	         */
			function upHandler(tp){
				if(tp == "ok"){
					ctp.data.getJSONA({	
						url:'<ctp:url href="cfsadsinfomain.flowc" flowActionName="adsup"/>',
						reqData : "system=" + v_cfsadsinfoId,
						success :function(data){
									if(data && data[0].retCode =="0"){
										ctpMSB.alert({title :'启用记录', message:'启用成功'});
										var url = '<ctp:url href="cfsadsinfomain.flowc" flowActionName="querycfsadsinfo" />'+ '&fetchNum=36&begNum='+((prolist.footer.getCurPage()-1)*12+1)+getQueryInfo();;
										prolist.loadData(url);
									}							
									else {
										ctpMSB.alert({title:'启用记录',message:'启用失败'});
									}
								}
					});
			 	}
			}
			/*
	         * @method deleteRecords
	         * @desc  删除信息
	         * @author user
	         */      
            function deleteRecords(){
                var confirmFlag = false;
                /*如果选择了数据，弹出确认删除对话框*/
                if(isChecked()){
        			ctpMSB.confirm({
        				title:'<ctp:label key="delete_record"/>',
        				message:'<ctp:label key="delete_continue"/>',
        				handler:delHandler
        			  });
                }else{
                	ctpMSB.alert({message:'<ctp:label key="delete_select"/>',title:'<ctp:label key="error_tips"/>',btn:[['确定','OK']],closeBtn:false});
                }
            }

            /*
	         * @method upRecord
	         * @desc  启用
	         * @author user
	         */      
            function upRecord(){
                var confirmFlag = false;
                /*如果选择了数据，弹出确认删除对话框*/
                if(isChecked()){
        			ctpMSB.confirm({
        				title:'启用记录',
        				message:'即将启用所选择的记录，是否继续？',
        				handler:upHandler
        			  });
                }else{
                	ctpMSB.alert({message:'<ctp:label key="请选择要启用的数据"/>',title:'<ctp:label key="error_tips"/>',btn:[['确定','OK']],closeBtn:false});
                }
            }
            /*
	         * @method submitForm
	         * @desc  表单提交
	         * @author user
	         */ 
            function submitForm(){
            	var url='<ctp:url href="cfsadsinfomain.flowc" flowActionName="querycfsadsinfo" params="language=\'zh_CN\';begNum=1;fetchNum=1;"/>'+getQueryInfo();
            	prolist.loadData(url);
            }
            /*
	         * @method resetForm
	         * @desc  表单重置
	         * @author user
	         */ 
            function resetForm(){
            	queryForm.reset();
            }

            /*
	         * @method getQueryInfo
	         * @desc  获取表单查询条件
	         * @author user
	         */ 
            function getQueryInfo(){
                var queryInfo = "&system="				
					+"&httpPath=" 					
					+"&filePath=" ;

                return queryInfo;
            }

            /*
	         * @method queryInfosExport
	         * @desc  查询结果导出
	         * @author user
	         */ 
            function queryInfosExport(){
                var url='<ctp:url href="cfsadsinfomain.flowc" flowActionName="opFileExport"/>'+getQueryInfo();
                window.location.href=url;
            }
            
        </script>
        <script type='text/javascript' kind='ui'>

            $(window).load(function(){
      		     //================================UI变量定义片段============================================================
                toolbar1 = new ctp.ui.toolbar({
                    id: 'toolbar1',
                    leftItems: [
                        {
                            type: 'button',
                            id: 'modify',
                            name: 'modify',
                            text: '<ctp:label key="modify"/>',
                            icon: 'edit',
                            onClick : modifyRecord
                        },
                        '-'
                        ,
                        {
                            type: 'button',
                            id: 'up',
                            name: 'up',
                            text: '启用',
                            icon: 'apply',
                            onClick : upRecord
                        },
                        '-'
                        ,
                        {
                            type: 'button',
                            id: 'delete',
                            name: 'delete',
                            text: '禁用',
                            icon: 'delete',
                            onClick : deleteRecords
                        }
                        
                    ]
                });

                prolist = new ctp.ui.grid({
                    id: 'prolist',
                    title:'列表',
                    toolbar:toolbar1,
                    toolbarPos:'innertop',
                    onSelect:function(){data=prolist.getAllSelectedData();                    	
                    if(data[0].flag=='禁用')
	                    {
	                    	toolbar1.setDisable("up",false,"left");
	              		  	toolbar1.setDisable("delete",true,"left");
	              		
	                    }   
	                    if(data[0].flag=='启用')
	                    {
	                		toolbar1.setDisable("up",true,"left");
	          		    	toolbar1.setDisable("delete",false,"left");
	                    }
	      		   
	            	}, 
                    header: {
                        title: [
                            [
                                {text: '',width: '80px'}
                                ,

									{			
										text: '序号',width: '30px'
									},	
									{			
										text: '系统'
									},								
									{			
										text: '状态'
									},							
									{			
										text: '<ctp:label key="httpPath"/>'
									},								
									{			
										text: '<ctp:label key="filePath"/>'
									},								
									{			
										text: '链接地址'
									}								                                
                            ]
                        ],
                        rowIdFieldName: "system",
                        attr: [
							{colType: 'radiobox'},

                            {fieldName: 'system',
							 css:{"text-align":"center"}
                            },
                            {	
                            	fieldName: 'systemName',css:{"text-align":"center"}
								                            },	
                            {	
                            	fieldName: 'flag',css:{"text-align":"center"}
								                            },						
                            {	
	                            	fieldName: 'httpPath',css:{"text-align":"center"}
									                            },
                            {	
	                            	fieldName: 'filePath',css:{"text-align":"center"}
									                            },
                            {	
                            	fieldName: 'url',css:{"text-align":"center"}
								                            }                                                          
                        ]
                    },
                    url:'<ctp:url href="cfsadsinfomain.flowc" flowActionName="querycfsadsinfo" params="language=\'zh_CN\';begNum=1;fetchNum=1;"/>'
                    ,
                    footer: {
						auto:true                    
                    }
                    
                });

              
                borderlayout1 = new ctp.ui.borderlayout({
                    id:'borderlayout1',
                    type: '1C',
                    //north__size: 0.3,
                    //north__items:[querycondition],
                    center__items:[prolist],
                    north__closable:false,
                    north__resizable : true,
                    renderTo: 'body'
                });
            });
        </script>


    </head>
    <body>

        <ctp:form name="queryForm" method="post" action="cfsadsinfomain.flowc" flowActionName="">
        	
        </ctp:form>

    </body>
</html>
